#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 23:11:37 2018
@project: 天池比赛-A股主板上市公司公告信息抽取
@group: MZH_314
@author: LHQ
"""
from array import array


def strQ2B(ustring):  
    """全角转半角"""  
    chars = array('u')
    for uchar in ustring:
        inside_code = ord(uchar)
        if inside_code == 12288:    #全角空格直接转换
            inside_code = 32
        elif (inside_code >= 65281 and inside_code <= 65374): #全角字符（除空格）根据关系转化
            inside_code -= 65248
        chars.append(chr(inside_code))
    return "".join(chars)
 
    
if __name__ == "__main__":
    s = "（），。：？！"
    s2 = strQ2B(s)
    print(s)
    print(s2)
